package com.shujia.wyh.day10;

import java.util.HashSet;
import java.util.Set;

public class SetDemo2 {
    public static void main(String[] args) {
        //当对象的成员变量值一样的时候，我们就认为是同一个对象，就要进行去重
        Set<Teacher> set1 = new HashSet<>();

        //创建元素对象
        Teacher t1 = new Teacher("笑哥", 29);
        Teacher t2 = new Teacher("小虎", 18);
        Teacher t3 = new Teacher("童哥", 19);
        Teacher t4 = new Teacher("小虎", 18);
        Teacher t5 = new Teacher("凯哥", 20);



        //将元素添加到集合中
        set1.add(t1);
        set1.add(t2);
        set1.add(t3);
        set1.add(t4);
        set1.add(t5);

        System.out.println(set1);
    }
}
